CS 211 Lesson 17

Advanced Plotting

Quote:

True genius resides in the capacity for evaluation of uncertain, hazardous, and conflicting information.  Winston Churchill

Lesson Objectives:

Lesson:

I. MATLAB Concepts

A. Plotting overview (review from last lesson)

B. Pie Charts

B. Bar Charts

C. Histograms (graphs)

Example 1 Example 2
% hist(vector, number_of_bins)

hist( [1 2 3 4 1 2 3 1 2 1], 2 );
 

% hist(vector, vector_of_bin_center_pts)

hist( rand(1,1000), [0.2 0.3 0.7] ); 

D. Scatter plots (graphs)


E.  3-D plots

Example 1 Example 2
% plot3(vector, vector, vector)

t = 0:pi/50:10*pi;
plot3(sin(t),cos(t),t);
grid('on');

% plot3(matrix, matrix, matrix)

plot3( [1 2; 3 4; 5 5], ...
       [1 2; 4 5; 2 3], ...
       [1 2; 5 6; 1 1]);
grid('on');
 
Example 1 Example 2
% mesh(matrix)

t = 0:pi/10:2*pi;
heights = sin(t)'*cos(t);
mesh(heights);
grid('on');

% mesh(x_matrix, y_matrix, z_matrix)

[x y] = meshgrid(0:pi/10:2*pi);
heights = sin(x)'*cos(x);
mesh(x, y, heights);
grid('on');
 

 

F.  Plot manipulation and queries

II. Good Programming Practices

III. Algorithms

 

Lab Work: Lab 17

References:  Chapman Textbook: sections 5.4-5.5